require("SOD/model/DrawModel")
require("SOD/tools/observers/FootprintObserver")
#require("SOD/tools/observers/PointArrayObserver")

module SOD
  
  class DrawFootprint < DrawModel
      
    def initialize
      #super
    end
    
    def draw(bar, active_model)
      super
      
      fpGroup = Sketchup.active_model.active_entities.add_group
      fpGroup.name = bar.name + "_Footprint"
      fp_ents = fpGroup.entities
      
      fpGroup.move! @origin
      rotation = Geom::Transformation.rotation(@origin, [0, 0, 1], @angle)
      fpGroup.transform! rotation
      
      face = fp_ents.add_face( [0, 0, 0], [@length, 0, 0], [@length, @width, 0], [0, @width, 0] )
      
      #face = Sketchup.active_model.active_entities.add_face(@pts)
      puts bar.footprintID = face.entityID
      #@pts.each do |pt|
      #  pointObserver = PointArrayObserver.new
      #  pt.add_observer pointObserver
      #end
      footprintFaceObserver = FootprintFaceObserver.new
      face.add_observer footprintFaceObserver
      face.material = "SOD_Footprint"
      
      footprintGroupObserver = FootprintGroupObserver.new
      fpGroup.add_observer footprintGroupObserver
      footprintInstanceObserver = FootprintInstanceObserver.new
      fpGroup.add_observer footprintInstanceObserver
      
    end
      
  end
  
end

module SOD
  
  class DrawCore
      
    def initialize
      #super
    end
    
    def draw(pts)
      originalLayer = Sketchup.active_model.active_layer
      activeLayer = Sketchup.active_model.layers.add "Footprints"
      Sketchup.active_model.active_layer = activeLayer
      core_group = Sketchup.active_model.active_entities.add_group
      core_group.name = "Core"
      
      core_ents = core_group.entities
      
      face = core_ents.add_face(pts)
      
      #@footprintObserver = FootprintObserver.new
      #face.add_observer @footprintObserver
      face.material = "SOD_Core"
      #face.back_material = "SOD_Core_back"
      Sketchup.active_model.active_layer = originalLayer
    end
      
  end
  
end
